<?php

namespace addons\kupay;

use app\common\library\Menu;
use think\Addons;

/**
 * 插件
 */
class Kupay extends Addons
{

    protected $menu = [
        [
            'name' => 'kupay', 'title' => '工资条管理', 'icon' => 'fa fa-graduation-cap', 'ismenu' => '1', 'weigh' => '10',
            'sublist' => [
                [
                    'name' => 'kupay/paylog/shows', 'title' => '首页', 'icon' => 'fa fa-home', 'ismenu' => '1', 'weigh' => '100',
                    'sublist' => [
                        ['name' => 'kupay/paylog/showtypman', 'title' => '内置函数', 'icon' => 'fa fa-circle-o', 'ismenu' => '0', 'weigh' => '0'],
                        ['name' => 'kupay/paylog/showtypprice', 'title' => '内置函数', 'icon' => 'fa fa-circle-o', 'ismenu' => '0', 'weigh' => '0'],
                    ]
                ],
                [
                    'name' => 'kupay/paylog', 'title' => '新增工资条', 'icon' => 'fa fa-wpforms', 'ismenu' => '1', 'weigh' => '80',
                    'sublist' => [
                        ['name' => 'kupay/paylog/index', 'title' => '新增工资条', 'icon' => 'fa fa-circle-o', 'ismenu' => '0', 'weigh' => '0'],
                        ['name' => 'kupay/paylog/infos', 'title' => '内置函数', 'icon' => 'fa fa-circle-o', 'ismenu' => '0', 'weigh' => '0'],
                        ['name' => 'kupay/paylog/sendsave', 'title' => '内置函数', 'icon' => 'fa fa-circle-o', 'ismenu' => '0', 'weigh' => '0'],
                        ['name' => 'kupay/paylog/sends', 'title' => '内置函数', 'icon' => 'fa fa-circle-o', 'ismenu' => '0', 'weigh' => '0'],
                        ['name' => 'kupay/paylog/sendsone', 'title' => '内置函数', 'icon' => 'fa fa-circle-o', 'ismenu' => '0', 'weigh' => '0'],
                        ['name' => 'kupay/paylog/sendsones', 'title' => '内置函数', 'icon' => 'fa fa-circle-o', 'ismenu' => '0', 'weigh' => '0'],
                        ['name' => 'kupay/paylog/sendsoneall', 'title' => '内置函数', 'icon' => 'fa fa-circle-o', 'ismenu' => '0', 'weigh' => '0'],
                        ['name' => 'kupay/paylog/sendsoneallerr', 'title' => '内置函数', 'icon' => 'fa fa-circle-o', 'ismenu' => '0', 'weigh' => '0'],
                        ['name' => 'kupay/paylog/type', 'title' => '薪资类型', 'icon' => 'fa fa-circle-o', 'ismenu' => '0', 'weigh' => '0'],
                        ['name' => 'kupay/paylog/typesave', 'title' => '薪资保存', 'icon' => 'fa fa-circle-o', 'ismenu' => '0', 'weigh' => '0'],
                        ['name' => 'kupay/paylog/paytypeedit', 'title' => '薪资编辑', 'icon' => 'fa fa-circle-o', 'ismenu' => '0', 'weigh' => '0'],
                        ['name' => 'kupay/paylog/typeupdate', 'title' => '薪资更新', 'icon' => 'fa fa-circle-o', 'ismenu' => '0', 'weigh' => '0'],
                        ['name' => 'kupay/paylog/typedel', 'title' => '薪资删除', 'icon' => 'fa fa-circle-o', 'ismenu' => '0', 'weigh' => '0'],
                        ['name' => 'kupay/paylog/import', 'title' => '导入', 'icon' => 'fa fa-circle-o', 'ismenu' => '0', 'weigh' => '0'],
                    ]
                ],
                [
                    'name' => 'kupay/setlog', 'title' => '发送记录', 'icon' => 'fa fa-file', 'ismenu' => '1', 'weigh' => '70',
                    'sublist' => [
                        ['name' => 'kupay/setlog/index', 'title' => '查看', 'icon' => 'fa fa-circle-o', 'ismenu' => '0', 'weigh' => '0'],
                        ['name' => 'kupay/setlog/info', 'title' => '发送记录', 'icon' => 'fa fa-circle-o', 'ismenu' => '0', 'weigh' => '0'],
                        ['name' => 'kupay/setlog/exports', 'title' => '导出', 'icon' => 'fa fa-circle-o', 'ismenu' => '0', 'weigh' => '0'],
                        ['name' => 'kupay/setlog/infodetails', 'title' => '详情', 'icon' => 'fa fa-circle-o', 'ismenu' => '0', 'weigh' => '0'],
                        ['name' => 'kupay/setlog/infoedit', 'title' => '编辑', 'icon' => 'fa fa-circle-o', 'ismenu' => '0', 'weigh' => '0'],
                        ['name' => 'kupay/setlog/infosave', 'title' => '保存', 'icon' => 'fa fa-circle-o', 'ismenu' => '0', 'weigh' => '0'],
                        ['name' => 'kupay/setlog/import', 'title' => '导入', 'icon' => 'fa fa-circle-o', 'ismenu' => '0', 'weigh' => '0'],
                    ]
                ],
                [
                    'name' => 'kupay/compay', 'title' => '公司信息', 'icon' => 'fa fa-cubes', 'ismenu' => '1', 'weigh' => '60',
                    'sublist' => [
                        ['name' => 'kupay/compay/index', 'title' => '查看', 'icon' => 'fa fa-circle-o', 'ismenu' => '0', 'weigh' => '0'],
                        ['name' => 'kupay/paylog/infosave', 'title' => '保存', 'icon' => 'fa fa-circle-o', 'ismenu' => '0', 'weigh' => '0'],
                    ]
                ],
                [
                    'name' => 'kupay/paylog/config', 'title' => '发送配置', 'icon' => 'fa fa-cubes', 'ismenu' => '1', 'weigh' => '50',
                    'sublist' => [
                        ['name' => 'kupay/paylog/configsave', 'title' => '保存', 'icon' => 'fa fa-circle-o', 'ismenu' => '0', 'weigh' => '0'],
                    ]
                ],
            ]
        ]
    ];

    /**
     * 插件安装方法
     * @return bool
     */
    public function install()
    {
        Menu::create($this->menu);
        return true;
    }

    /**
     * 插件卸载方法
     * @return bool
     */
    public function uninstall()
    {
        Menu::delete("kupay");
        return true;
    }

    /**
     * 插件启用方法
     * @return bool
     */
    public function enable()
    {
        Menu::enable("kupay");
        return true;
    }

    /**
     * 插件禁用方法
     * @return bool
     */
    public function disable()
    {
        Menu::disable("kupay");
        return true;
    }

    /**
     * 插件升级方法
     * @return bool
     */
    public function upgrade()
    {
        //如果菜单有变更则升级菜单
        Menu::upgrade('kupay', $this->menu);
        return true;
    }

}
